/********************************************************************************************************
 * @file	gap_stack.h
 *
 * @brief	This is the header file for BLE SDK
 *
 * @author	BLE GROUP
 * @date	2020.06
 *
 * @par     Copyright (c) 2020, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
 *          All rights reserved.
 *
 *          Redistribution and use in source and binary forms, with or without
 *          modification, are permitted provided that the following conditions are met:
 *
 *              1. Redistributions of source code must retain the above copyright
 *              notice, this list of conditions and the following disclaimer.
 *
 *              2. Unless for usage inside a TELINK integrated circuit, redistributions
 *              in binary form must reproduce the above copyright notice, this list of
 *              conditions and the following disclaimer in the documentation and/or other
 *              materials provided with the distribution.
 *
 *              3. Neither the name of TELINK, nor the names of its contributors may be
 *              used to endorse or promote products derived from this software without
 *              specific prior written permission.
 *
 *              4. This software, with or without modification, must only be used with a
 *              TELINK integrated circuit. All other usages are subject to written permission
 *              from TELINK and different commercial license may apply.
 *
 *              5. Licensee shall be solely responsible for any claim to the extent arising out of or
 *              relating to such deletion(s), modification(s) or alteration(s).
 *
 *          THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 *          ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 *          WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *          DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
 *          DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 *          (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *          LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *          ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *          (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *          SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *******************************************************************************************************/
#ifndef STACK_BLE_GAP_STACK_H_
#define STACK_BLE_GAP_STACK_H_





typedef int (*host_ota_mian_loop_callback_t)(void);
typedef int (*host_ota_terminate_callback_t)(u16);
extern host_ota_mian_loop_callback_t    		host_ota_main_loop_cb;
extern host_ota_terminate_callback_t    		host_ota_terminate_cb;







/******************************* gap event start ************************************************************************/

extern u32		gap_eventMask;


int blc_gap_send_event (u32 h, u8 *para, int n);

/******************************* gap event  end ************************************************************************/



/******************************* gap start ************************************************************************/

typedef struct
{
	u16 effective_MTU;
	u16 indicate_handle;

	u8 *pPendingPkt;

	u16 mtu_exg_pending;
	u16 rsvd;

}gap_ms_para_t;

typedef struct
{
	u16 	l2cap_connParaUpdateReq_minIntevel;
	u16 	l2cap_connParaUpdateReq_maxInterval;
	u16 	l2cap_connParaUpdateReq_latency;
	u16 	l2cap_connParaUpdateReq_timeout;

	u8		l2cap_connParaUpReq_pending;
	u8 		data_pending_time;    //10ms unit
	u8      rsvd[2];
	u32 	l2cap_connParaUpReqSendAfterConn_us;

	u32 	att_service_discover_tick;

}gap_s_para_t;



extern gap_ms_para_t gap_ms_para[];
extern gap_s_para_t  gap_s_para[];



int blt_gap_conn_complete_handler(u16 connHandle, u8 *p);
int blt_gap_conn_terminate_handler(u16 connHandle, u8 *p);
u8  blt_gap_getSlaveDeviceIndex_by_connIdx(u8 conn_idx);

gap_s_para_t 	*bls_gap_getSlavepara(u16 connHandle);
gap_ms_para_t 	*blc_gap_getMasterSlavePara(u16 connHandle);

#if(LL_MULTI_SLAVE_MAC_ENABLE)
int         blc_gap_getSlaveDeviceIndex_by_localMac(u8 local_addr_type, u8 *local_addr);
#endif


/******************************* gap end ************************************************************************/


#endif /* GAP_STACK_H_ */
